package com.ruiyun.app.lib.crash

import android.annotation.SuppressLint
import android.content.Context
import android.util.Log
import androidx.annotation.NonNull
import androidx.work.ListenableWorker
import androidx.work.WorkerParameters
import androidx.work.impl.utils.futures.SettableFuture
import com.google.common.util.concurrent.ListenableFuture
import com.umeng.analytics.MobclickAgent

class UploadCatchUncaughtWorker(appContext: Context, workerParams: WorkerParameters) : ListenableWorker(appContext, workerParams) {
    @SuppressLint("RestrictedApi")
    @NonNull
    override fun startWork(): ListenableFuture<Result> {
        var mFuture = SettableFuture.create<Result>()
        val msg = inputData.getString("msg")
        MobclickAgent.reportError(applicationContext, msg)
        mFuture.set(Result.success())
        Log.e("UploadUncaughtWorker", "错误日志上传成功")
        return mFuture
    }
}
